
class Money implements Cloneable{
    public double money=19.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
class Person implements Cloneable{
    public int age=10;
   public Money m =new Money();

    @Override
    protected Object clone() throws CloneNotSupportedException {

        Person tmp=(Person) super.clone();//克隆的是Person里的内容
        tmp.m= (Money) this.m.clone();//克隆的是Money的内容

        return tmp;

    }
}

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {

        Person person=new Person();
        Person person1=(Person) person.clone();//深拷贝拷贝出Person内容的另一个副本
        System.out.println(person.m.money);
        person1.m.money=29.6;//深拷贝改变副本里面的内容，原内容不变
        System.out.println(person1.m.money);


    }


}
